package cn.com.victorysoft.ylgl.service.fracturingpressure.service.fracturing.impl;
import cn.com.victorysoft.ylgl.service.commons.mybatis.MybatisRepository;
import cn.com.victorysoft.ylgl.service.commons.util.IDUtils;
import cn.com.victorysoft.ylgl.service.fracturingpressure.domain.PressureConstructionChild;
import cn.com.victorysoft.ylgl.service.fracturingpressure.service.fracturing.IPressureConstructionChildService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 主压施工参数
 * Created by Administrator on
 */
@org.springframework.stereotype.Component
public class PressureConstructionChildService implements IPressureConstructionChildService {
    private static final Logger logger = LoggerFactory.getLogger(PressureConstructionChildService.class);
    @Resource
    private MybatisRepository mybatisRepository;
    @Override
    public PressureConstructionChild getById(String dataId) {
        Map<String, Object> params = new HashMap<>();
        params.put("dataId", dataId);
        return this.mybatisRepository.selectOne(
                "cn.com.victorysoft.ylgl.webapp.service.fracturingPressure.PressureConstructionChildMapper.selectByPrimaryKey",
                params);
    }

    @Override
    public List<PressureConstructionChild> queryList(String parentId) {
        Map<String, Object> params = new HashMap<>();
        params.put("parentId", parentId);

        List<PressureConstructionChild> dataPaging = this.mybatisRepository.selectByParams(
                "cn.com.victorysoft.ylgl.webapp.service.fracturingPressure.PressureConstructionChildMapper.selectList",
                params);
        return dataPaging;
    }

    @Override
    public int deleteByParentId(String parentId) {
        Map<String, Object> params = new HashMap<>();
        params.put("parentId", parentId);
        this.mybatisRepository.delete(
                "cn.com.victorysoft.ylgl.webapp.service.fracturingPressure.PressureConstructionChildMapper.deleteByParentId",params);
        return 1;
    }


    @Override
    public int insert(PressureConstructionChild record) {
        record.setDataId(IDUtils.getUUID32());
        this.mybatisRepository.insert("cn.com.victorysoft.ylgl.webapp.service.fracturingPressure.PressureConstructionChildMapper.insert",record);
        return 1;
    }

    /**
     * @param dataids id以;隔开，比如：1;2;
     * @return 返回影响的行数
     */
    @Override
    public int deleteByKeys(String dataids) {
        Map<String, Object> params = new HashMap<>();
        params.put("dataIds", dataids);
        this.mybatisRepository.delete(
                "cn.com.victorysoft.ylgl.webapp.service.fracturingPressure.PressureConstructionChildMapper.deleteByKeys",params);
        return 1;
    }

    @Override
    public int deleteByPrimaryKey(String dataId) {
        Map<String, Object> params = new HashMap<>();
        params.put("dataId", dataId);
        this.mybatisRepository.delete(
                "cn.com.victorysoft.ylgl.webapp.service.fracturingPressure.PressureConstructionChildMapper.deleteByPrimaryKey",params);
        return 1;
    }

    @Override
    public int updateByPrimaryKey(PressureConstructionChild record) {
        this.mybatisRepository.update("cn.com.victorysoft.ylgl.webapp.service.fracturingPressure.PressureConstructionChildMapper.updateByPrimaryKey",record);
        return 1;
    }

}
